<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file ="../include/base.jsp"%>
<!DOCTYPE HTML>
<html lang="en-US">
<head>
	<meta charset="UTF-8">
	<link rel="stylesheet" type="text/css"  href="<%=basePath %>css/bootstrap.min.css"/>
	<link rel="stylesheet" type="text/css" href="<%=basePath %>css/datepicker.css" />
	<link rel="stylesheet" type="text/css" href="<%=basePath %>css/task.css" />
	
	<title>凯胜项目管理系统</title>
	<style type="text/css">
		body{
			padding-top:50px;
		}
		.mywell{
			margin-top:25px;
		
		}
		.mybox3{border:1px solid #ccc; border-radius:5px; margin: 100px; position:absolute;top:180px;left:850px;z-index:1;background-color: #fff;}
        
	</style>
</head>
<body class="body" style ="padding-left:180px;" id="body2"> 
		<%@ include file = "../include/sametop.jsp" %>
		<jsp:include page="../include/sameleft.jsp">
			<jsp:param value="deal" name="tag"/>
		</jsp:include>
		<input type="hidden" value="${deal.id }" id = "getDealid"/>
			<div  style=" border:1px solid #dddddd;margin-left:260px;margin-top:25px;width:800px;min-height:600px;">
				<div style = "background-color:#ededed">
					<div class = ""  style = "margin-left:0px;margin-top:20px;">
						
					  <div class = "span1" ><img src="<%=basePath %>img/10.png" style = "box-shadow:20px,20px"alt="" /></div>
					  <div class = "span8"><span style = "font-size:24px;font-weight:bold;color:#08c">${deal.name }</span>&nbsp;<span>with&nbsp;&nbsp;${deal.contactname}</span>&nbsp;&nbsp;<span>${deal.priceChangeState}</span><br />总金额：${deal.price }
	
						  <div style ="float:right;margin-top:10px">
							  <div><a href="<%=basePath %>deal/editDeal.action?id=${deal.id}" style ="float:right;margin-top:-25px">编辑这个交易</a> </div>
							   <c:if test="${deal.progress == 'pend'}">
							   		<a id = "pend" class = "btn btn-danger" style = "width:50px;margin-right:-4px;border-right:none" href="javaScript:;">跟进</a>
									<a id = "won" class = "btn" style = "width:50px;margin-left:0px" href="javaScript:;">赢得</a>
									<a id = "lost" class = "btn" style = "width:50px;margin-right:0px" href="javaScript:;">失去</a>
							   
							   </c:if>
							   <c:if test="${deal.progress == 'won'}">
							   		<a id = "pend" class = "btn" style = "width:50px;margin-right:-4px;border-right:none;" href="javaScript:;">跟进</a>
									<a id = "won" class = "btn btn-success" style = "width:50px;margin-left:0px" href="javaScript:;">赢得</a>
									<a id = "lost" class = "btn" style = "width:50px;margin-right:0px" href="javaScript:;">失去</a>
							   
							   </c:if>
							   <c:if test="${deal.progress == 'lost'}">
							   		<a id = "pend" class = "btn " style = "width:50px;margin-right:-4px;border-right:none" href="javaScript:;">跟进</a>
									<a id = "won" class = "btn" style = "width:50px;margin-left:0px" href="javaScript:;">赢得</a>
									<a id = "lost" class = "btn active" style = "width:50px;margin-right:0px" href="javaScript:;">失去</a>
							   
							   </c:if>
							</div>	  
					
					  <div style = "border:1px solid #cdcdcc;width:800px;margin-top:50px;margin-left:-100px"></div>
					 
					
				
				</div>
				</div>
			</div>
			
			<div style ="margin-top:150px;height:auto;">
				<div style = "border-left:1px solid #cccccc;float:right">
					<div style = "margin-left:20px"><h4 >日程安排&nbsp;&nbsp;&nbsp;&nbsp;<a href="javaScript:;" id= "addTask1">添加</a></h4>
					<div class="box mybox3" id = "box31" style ="display:none">
				        <div class="abox">
				            <div class="a1"></div>
				            <div class="a2"></div>
				            
				        </div>
				        <div style = "margin-left:15px;margin-top:15px;">
				            <strong>添加日程安排</strong><br/>
							<input type="text"  id = "taskname1"/><br/>
							<input type = "hidden" id="deid" value="${deal.id}">
							 <strong>时间安排</strong><br/>
							 	<input type = "text" style ="display:none;width:140px" id = "settimeinput1" />
								<select id = "selecttime1" style = "width:150px">
												<option value="today">今天</option>
												<option value="tomorrow">明天</option>
												<option value="thisweek">这周</option>
												<option value="nextweek">下周</option>
												<option value="later">更晚</option>
											
									
								</select><a href="javaScript:;" id = "settimebtn1" class = "ui-datepicker-trigger">设置时间</a><br/>
								
								 <strong>选择类别</strong><br/>
								<select style = "width:150px" id="leibie1"> 
												
												<option value="none">none</option>
												<c:forEach items="${taskTypeList}" var ="taskType">
													<option value="${taskType.id}">${taskType.typeContent }</option>
												</c:forEach>
								</select><span><a href = "<%=basePath%>task/taskType.action">编辑类别</a></span><br/>
								<div style = "border:1px solid #cdcdcc;width:200px;margin-top:10px;margin-bottom:5px;"></div>
								<button class = "btn btn-success" style = "margin-left:140px;margin-bottom:15px;" id="addNewTask1">添加</button>
				
							
				          </div>
				       
				    </div>
					<div style = "margin-left:10px" id="mytaskList">
					
				
						<c:forEach items = "${dealTaskList}" var="task">
							<h4 class = "${task.dataType} mydataType" style = "margin-bottom:5px;margin-top:8px;">${task.dataType}</h4>
								<div style = "width:200px" class = "taskaboutdeal">
									<span class = "myspan" style="margin-left:-40px;display:none"><a href="javaScript:;" class = "deltaskaboutdeal" id = "${task.id}"><i class = "icon-trash"></i></a><a>编辑</a></span>
									<span><span style = "margin-right:10px" id="num"><input id = "${task.id}" type="checkbox" style = "margin-left:5px" class = "mycheck"/></span><span  style = "color:#fff;height:15px;background-color:${task.taskType.color};margin-right:5px"><font>${task.taskType.typeContent }</font></span><span>${task.content }</span></span>
									
								</div>
								
						</c:forEach>
				
					</div>
					<h4>背景信息&nbsp;&nbsp;<a href="javaScript:;">编辑或添加</a></h4>
					<c:choose>
						<c:when test = "${deal.background == null}"><div style = "margin-top:10px;font-size:12px">无相关的背景信息</div></c:when>
						<c:otherwise><div style = "margin-top:10px;font-size:12px">${deal.background}</div></c:otherwise>
						
					
					</c:choose>
					
					<h4 style = "margin-top:10px">和这笔交易相关的联系人&nbsp;&nbsp;&nbsp;<a href="javaScript:;" id="addothercontact">添加联系人</a></h4>
					
					<div class = "searchothercontact" style = "margin-top:10px;display:none">搜索相关联系人<br/>
					<input type="hidden" name="contactid" class="input-xlarge"  id="searchhidden" value="">
					<input type="hidden"  class="input-xlarge"  id="searchdealid" value="${deal.id }">
					<input type="text" value = "search" id="searchContact"/><a href = "javaScript:;" id = "toAdd">添加</a>
					<div class = "input-xlarge show" style = "display:none;width:220px;margin-top:-8px;border-radius: 3px;border: 1px solid #CCC;background-color:#ffc">
					</div>
					</div>
					<div id = "toaddContact" style = "margin-top:10px">
						<c:forEach items ="${deal.dcSet }" var = "dc">
							<div style = "margin-bottom:20px">
							<c:choose>
								<c:when test="${dc.contact.type == 'person' }">
								<img src = "<%=basePath%>img/3.png" style = "width:30px;height:30px;margin-left:25px"/><span style = "margin-left:15px"><strong><a class="dc2" href= "<%=basePath%>contact/singlecontact.action?id=${dc.contact.id}" id="${dc.contact.id}">${dc.contact.name}</a></strong><a class="editdcContact" href="javaScript:;" id="${dc.contact.id }"><i style="margin-left:10px;" class="icon-trash"></i></a></span> 
								</c:when>
								<c:otherwise>
									<div><img src = "<%=basePath%>img/10.png" style = "width:30px;height:30px;margin-left:25px"/><span style = "margin-left:15px"><strong><a class="dc2" href= "<%=basePath%>contact/singlecontact.action?id=${dc.contact.id}" id="${dc.contact.id}">${dc.contact.name}</a></strong><a class="editdcContact" href="javaScript:;" id="${dc.contact.id}"><i class="icon-trash"></i></a></span></div>
								</c:otherwise>
							</c:choose>
							</div>
						</c:forEach>
					
					</div>
					<br />
					</div>
				</div>
				<div class = "" style = "margin-left:20px;width:470px;margin-left:20px;">
				
					  <p class = "help-block" style = "font-weight:bold">添加相关的记录</p>
					  <form id = " form" method = "post" action = "<%=basePath%>note/adddealnote.action">
						<input type = "hidden" name ="dealid" id ="dealid" value="${deal.id }" />
						<textarea  name = "note.content" id="note.content" style = "width:380px;min-height:150px;overflow-y:visible;resize:none"/></textarea>
						<br/><a class= "showOptions" href="javaScript:;">选择更多...</a>(如：可见权限设置，选择具体的相关联系人)
						<div id = "myhiddennote" style = "display:none">
							<strong>与这个记录相关的联系人</strong><br>
							<p style = "font-size:12px" class=" mytip">(*选择与这笔交易相关的人或者是公司)</p>
								<c:if test="${deal.dcSet == null }">ccccc</c:if>
								<select name ="contactid" id = "contactid" >
									<option value = "">没有人</option>
									<c:forEach items = "${deal.dcSet }" var = "dealcontact">
										<option value = "${dealcontact.contact.id}" class="dc">${dealcontact.contact.name}</option>
									</c:forEach>
								</select>
								<br>
							<strong>设置可见的权限</strong>	<br>
							<input type ="radio"  name ="note.views" value="all">所有人 <br/>
							<input type ="radio" name ="note.views"  value="me">只有我<br/>
							<input type ="radio" name ="note.views" id = "radiobtn" value="all,other">我,和下面这些人<br/>
							<div id="showSelect" style="display:none">
							<select name=""  >
								<option value="">请选择</option>
								<option value="">张三</option>
								<option value="">王五</option>
								<option value="">李四</option>
								<option value="">小妹</option>
							</select>
							</div>
							<strong>记录具体发生的日期</strong>	
							
								<p>Date: <input name ="note.createtime"  type="text" id="d1"></p>	
							
						</div>
						 <button id = "myform" style = "margin-left:350px;" class = "btn btn-success">保存</button>
						</form>
						</div>
						
					  
				
				
				
				
				<div style = "margin-left:20px;width:450px;">
					<strong class = "">关于这个交易的相关记录</strong>
					<div style = "border:1px solid #cdcdcc;width:450px;margin-top:10px;margin-left:-15px"></div>
						
						<div id = "aboutnote1" style = "padding-top:30px;">
							<div id = "aboutnote"></div>
							<c:choose>
								<c:when test="${empty listNote }">
								<div>暂时无相关的记录</div>
								
								
								</c:when>
								<c:otherwise>
									<c:forEach items = "${listNote }" var = "note">
								
										<c:if test="${note.type == 'pend' }">
											<div style = 'margin-bottom:20px;background-color:#ededed;height:30px'><div style = 'background-color:#666;width:60px;height:20px;color:white;text-align:center;padding-top:4px;border-radius:6px 6px'>跟进</div><div style = 'margin-left:80px;margin-top:-20px;'>${note.content }</div></div>
										</c:if>
										<c:if test="${note.type == 'won' }">
											<div style = 'margin-bottom:20px;background-color:#ededed;height:30px'><div style = 'background-color:#51a351;width:60px;height:20px;color:white;text-align:center;padding-top:4px;border-radius:6px 6px'>赢得</div><div style = 'margin-left:80px;margin-top:-20px;'>${note.content}</div></div>
										</c:if>
										<c:if test="${note.type == 'lost' }">
											<div style = 'margin-bottom:20px;background-color:#ededed;height:30px'><div style = 'background-color:#900;width:60px;height:20px;color:white;text-align:center;padding-top:4px;border-radius:6px 6px'>失去</div><div style = 'margin-left:80px;margin-top:-20px;'>${note.content }</div></div>
										</c:if>
										<c:if test="${note.type == 'note' }">
											
									<div class = "mymouseover" id="${note.id }" style = "margin-bottom:30px;"><a class = "tocomment" style = "float:right;display:none" href = "javaScript:;" class ="editnote">查看记录并评论</a><div class = "myeditanddel" style = "float:left;display:none;margin-left:-40px;"><a href="javaScript:;" id = "${note.id}" class ="delnote" ><i class = "icon-trash"></i></a><a href="javaScript:;" id = "${note.id}" class ="editnote">编辑</a></div><img src = "<%=basePath %>img/10.png"/><div style = "margin-left:80px;margin-top:-45px;"><strong>${note.createtime }</strong><br/><span style = "color:red">${note.user.username }&nbsp;&nbsp;&nbsp;&nbsp;</span>添加的记录<br/><span><c:if test = "${note.contact !=null }">此条记录和${note.contact.name }相关</c:if></span><br><br><div style = "margin-left:0px;border-bottom:1px solid #dcdcdc;">${note.content}</div></div></div>
										
										
										</c:if>
										<c:if test="${note.type == 'noteaboutcontact' }">
											<div class = "mymouseover" id="${note.id }" style = "margin-bottom:60px;"><a class = "tocomment" style = "float:right;display:none" href = "javaScript:;" class ="editnote">查看记录并评论</a><div class = "myeditanddel" style = "float:left;display:none;margin-left:-40px;"><a href = "javaScript:;" id = "${note.id}" class ="delnote"><i class = "icon-trash"></i></a><a href = "javaScript:;" id = "${note.id}" class ="editnote" >编辑</a></div><img src = "<%=basePath %>img/3.png" style = "width:40px;height:40px"/><div style = "margin-left:80px;margin-top:-45px;"><span style = "font-size:20px"><a>${note.contact.name }&nbsp;&nbsp;&nbsp;</a></span>来自&nbsp;&nbsp;<a>${note.contact.company}</a><br><strong>${note.createtime }</strong><br/><span style = "color:red">${note.user.username }&nbsp;&nbsp;&nbsp;&nbsp;</span>添加的记录<br/><span><c:if test = "${note.contact !=null }">此条记录和${note.contact.name }相关</c:if></span><br><br><div style = "margin-left:0px;border-bottom:1px solid #dcdcdc;">${note.content}</div></div><div style = "margin-left:80px;margin-top:-45px"></div></div>
										</c:if>
							
							
							
							
									</c:forEach>
								
								
								</c:otherwise>
							
							
							
							
							</c:choose>
							
						
						
						</div>
						
					</div>
				
				</div>
				
			</div>
				<div class = "" id="mymodal2" style="width:400px;display:none;position:absolute;left:600px;top:140px;border:1px solid #ccc;border-radius:5px 5px;background-color:#fff;" >
							<textarea style="width:300px;height:200px" ></textarea>
							<hr>
							<div style = "margin-left:160px;margin-bottom:10px;">
								<input  id = "newtodelFiles" class = "btn btn-primary" value = "修改" type="submit"/>
								<a href="" class = "btn" id="quxiao" >取消</a>
							</div>
							</form>
						</div>	
	
	<script type="text/javascript" src="<%=basePath %>js/jquery.js"></script>
	<script type="text/javascript" src="<%=basePath %>js/bootstrap.js"></script> 
	<script type="text/javascript" src ="<%=basePath %>js/bootstrap-datepicker.js"></script>
	<script type="text/javascript">
		var flg = true;		
		var addTask = document.getElementById('addTask');		
		var box3 = document.getElementById('box3');				
		addTask.onclick = function(){	
			flg = false;			
			box3.style.display = 'block';		
		};	
		box3.onclick = function(){
			flg = false;
		};
		var flg1 = true;		
		var addTask1 = document.getElementById('addTask1');		
		var box31 = document.getElementById('box31');			
		var body1 = document.getElementById('body2');
		var selecttime1 = document.getElementById('selecttime1');			
		var settimeinput1 = document.getElementById('settimeinput1');		
		body1.onclick = function(){			
			if(flg1){ 
				selecttime1.style.display = 'inline';
				settimeinput1.style.display = 'none';
				box31.style.display = 'none';			
			}	
			flg1 = true;
			if(flg){ 
				selecttime.style.display = 'inline';
				settimeinput.style.display = 'none';
				box3.style.display = 'none';			
			}	
			flg = true;			
		};		
		addTask1.onclick = function(){	
			flg1 = false;			
			box31.style.display = 'block';		
		};	
		box31.onclick = function(){
			flg1 = false;
		};
			
			
	
		$(document).ready(function(){
			$(".tomorrow:not(:first)").remove();
			$(".today:not(:first)").remove();
			$(".thisweek:not(:first)").remove();
			$(".nextweek:not(:first)").remove();
			$(".later:not(:first)").remove();
			$(".overdue:not(:first)").remove();
			$("#addNewTask").click(function(){
			var taskname  = $("#taskname").val();
			var selecttime = $("#selecttime").val();
			var settimeinput= $("#settimeinput").val();
			var taskType="个人";
			var leibie= $("#leibie").val();
			if(settimeinput.length!=0){
				$.post("http://localhost:80/crm/task/addTask.action",{taskname:taskname,settimeinput:settimeinput,leibie:leibie,taskType:taskType},function(data){
					var type = data.dataType;
					
				});
				$(".box").hide();
				$("#tishi").show();
				$("#tishi").fadeOut(3500);
				  
			}else{
				//alert(taskname);
				//alert(selecttime);
				//alert(leibie);
				$.post("http://localhost:80/crm/task/addTask.action",{taskname:taskname,selecttime:selecttime,leibie:leibie,taskType:taskType},function(data){
					alert(data);
				});
				$(".box").hide();
				$("#tishi").show();
				$("#tishi").fadeOut(3500);
				
			}
			
			
			
			
		});
		$("#addNewTask1").click(function(){
			var taskname1  = $("#taskname1").val();
			var selecttime1 = $("#selecttime1").val();
			var settimeinput1= $("#settimeinput1").val();
			var taskType1=$("#deid").val();
			var leibie1= $("#leibie1").val();
			var id = $("#getDealid").attr("value");
		
			if(settimeinput1.length!=0){
				$.post("http://localhost:80/crm/task/addTask.action",{taskname:taskname1,settimeinput:settimeinput1,leibie:leibie1,taskType:taskType1,id:id},function(data){
					var type = data.dataType;
					var v = $("."+type).html();
					 var m = $("."+type).length;
					 if(m<=0){
					 	fun(type,data);
					 	
				     }else{
					 		$("."+v).after("<div style = 'width:200px' class = 'taskaboutdeal'><span class = 'myspan' style='margin-left:-40px;display:none'><a href='javaScript:;' class = 'deltaskaboutdeal' id = '${task.id}'><i class = 'icon-trash'></i></a><a>编辑</a></span><span><span style = 'margin-right:10px' id='num'><input id = '"+data.id+"' type='checkbox' style = 'margin-left:5px' class = 'mycheck'/></span><span  style = 'color:#fff;height:15px;background-color:"+data.taskType.color+";margin-right:5px'><font>"+data.taskType.typeContent+"</font></span><span>"+data.content+"</span></span></div>"); 
					 	
					 }
					 
				});
				$(".box").hide();
				$("#tishi").show();
				$("#tishi").fadeOut(3500);
				
				 
			}else{
				$.post("http://localhost:80/crm/task/addTask.action",{taskname:taskname1,selecttime:selecttime1,leibie:leibie1,taskType:taskType1,id:id},function(data){
					//$("#mytaskList").empty();
					//alert(data);
					/* for(var i=0;i<data.length;i++){
						$("#mytaskList").append("<h4 class = '"+data[i].dataType+" mydataType' style = 'margin-bottom:5px;margin-top:8px;'>"+data[i].dataType+"</h4><div style = 'width:200px' class = 'taskaboutdeal'><span class = 'myspan' style='margin-left:-40px;display:none'><a href="javaScript:;" class = "deltaskaboutdeal" id = "${task.id}"><i class = "icon-trash"></i></a><a>编辑</a></span><span style = 'margin-right:10px' id='num'><input type='checkbox' style = 'margin-left:5px'/></span><span  style = 'color:#fff;height:15px;background-color:"+data[i].taskType.color+";margin-right:5px'><font>"+data[i].taskType.typeContent+"</font></span>"+data[i].content+"</div>");
					
					} */
					
					/* var type = data.dataType;
					alert("hehe");
					alert($("."+type).html()); */
					
					var type = data.dataType;
					var v = $("."+type).html();
					 var m = $("."+type).length;
					 if(m<=0){
					 	fun(type,data);
					 	
				     }else{
					 		$("."+v).after("<div style = 'width:200px' class = 'taskaboutdeal'><span class = 'myspan' style='margin-left:-40px;display:none'><a href='javaScript:;' class = 'deltaskaboutdeal' id = '${task.id}'><i class = 'icon-trash'></i></a><a>编辑</a></span><span><span style = 'margin-right:10px' id='num'><input id = '"+data.id+"' type='checkbox' style = 'margin-left:5px' class = 'mycheck'/></span><span  style = 'color:#fff;height:15px;background-color:"+data.taskType.color+";margin-right:5px'><font>"+data.taskType.typeContent+"</font></span><span>"+data.content+"</span></span></div>"); 
					 	
					 }
				});
				$(".box").hide();
				$("#tishi").show();
				$("#tishi").fadeOut(3500);
			}
			
			
			
			
		});
		function fun(type,data){
			if(type=="today"){
		 		if($(".overdue").length>0){
		 			if($(".tomorrow").length>0){
		 				$(".tomorrow").insertBefore("<h4 class = '"+type+" mydataType xxx' style = 'margin-bottom:5px;margin-top:8px;'>"+type+"</h4>"); 
					 	$(".xxx").after("<div style = 'width:200px' class = 'taskaboutdeal'><span class = 'myspan' style='margin-left:-40px;display:none'><a href='javaScript:;' class = 'deltaskaboutdeal' id = '${task.id}'><i class = 'icon-trash'></i></a><a>编辑</a></span><span><span style = 'margin-right:10px' id='num'><input id = '"+data.id+"' type='checkbox' style = 'margin-left:5px' class = 'mycheck'/></span><span  style = 'color:#fff;height:15px;background-color:"+data.taskType.color+";margin-right:5px'><font>"+data.taskType.typeContent+"</font></span><span>"+data.content+"</span></span></div>"); 
		 			
		 			}else{
		 				if($(".thisweek").length>0){
					 			$(".thisweek").insertBefore("<h4 class = '"+type+" mydataType xxx' style = 'margin-bottom:5px;margin-top:8px;'>"+type+"</h4>"); 
					 			$(".xxx").after("<div style = 'width:200px' class = 'taskaboutdeal'><span class = 'myspan' style='margin-left:-40px;display:none'><a href='javaScript:;' class = 'deltaskaboutdeal' id = '${task.id}'><i class = 'icon-trash'></i></a><a>编辑</a></span><span><span style = 'margin-right:10px' id='num'><input id = '"+data.id+"' type='checkbox' style = 'margin-left:5px' class = 'mycheck'/></span><span  style = 'color:#fff;height:15px;background-color:"+data.taskType.color+";margin-right:5px'><font>"+data.taskType.typeContent+"</font></span><span>"+data.content+"</span></span></div>"); 
					 		}else{
					 			if($(".nextweek").length>0){
					 				$(".thisweek").insertBefore("<h4 class = '"+type+" mydataType xxx' style = 'margin-bottom:5px;margin-top:8px;'>"+type+"</h4>"); 
					 				$(".xxx").after("<div style = 'width:200px' class = 'taskaboutdeal'><span class = 'myspan' style='margin-left:-40px;display:none'><a href='javaScript:;' class = 'deltaskaboutdeal' id = '${task.id}'><i class = 'icon-trash'></i></a><a>编辑</a></span><span><span style = 'margin-right:10px' id='num'><input id = '"+data.id+"' type='checkbox' style = 'margin-left:5px' class = 'mycheck'/></span><span  style = 'color:#fff;height:15px;background-color:"+data.taskType.color+";margin-right:5px'><font>"+data.taskType.typeContent+"</font></span><span>"+data.content+"</span></span></div>"); 
					 			}else{
					 				if($(".later").length>0){
					 					$(".later").insertBefore("<h4 class = '"+type+" mydataType xxx' style = 'margin-bottom:5px;margin-top:8px;'>"+type+"</h4>"); 
					 					$(".xxx").after("<div style = 'width:200px' class = 'taskaboutdeal'><span class = 'myspan' style='margin-left:-40px;display:none'><a href='javaScript:;' class = 'deltaskaboutdeal' id = '${task.id}'><i class = 'icon-trash'></i></a><a>编辑</a></span><span><span style = 'margin-right:10px' id='num'><input id = '"+data.id+"' type='checkbox' style = 'margin-left:5px' class = 'mycheck'/></span><span  style = 'color:#fff;height:15px;background-color:"+data.taskType.color+";margin-right:5px'><font>"+data.taskType.typeContent+"</font></span><span>"+data.content+"</span></span></div>"); 
						 			}else{
						 				$("#mytaskList").append("<h4 class = '"+type+" mydataType xxx' style = 'margin-bottom:5px;margin-top:8px;'>"+type+"</h4>");
					 					$(".xxx").after("<div style = 'width:200px' class = 'taskaboutdeal'><span class = 'myspan' style='margin-left:-40px;display:none'><a href='javaScript:;' class = 'deltaskaboutdeal' id = '${task.id}'><i class = 'icon-trash'></i></a><a>编辑</a></span><span><span style = 'margin-right:10px' id='num'><input id = '"+data.id+"' type='checkbox' style = 'margin-left:5px' class = 'mycheck'/></span><span  style = 'color:#fff;height:15px;background-color:"+data.taskType.color+";margin-right:5px'><font>"+data.taskType.typeContent+"</font></span><span>"+data.content+"</span></span></div>"); 
						 			
						 			}
					 			
					 			}
					 		
					 		}
		 			
		 			
		 			}
		 			
		 		
		 		}else{
		 			$("#mytaskList").prepend("<h4 class = '"+type+" mydataType xxx' style = 'margin-bottom:5px;margin-top:8px;'>"+type+"</h4>");
		 			$(".xxx").after("<div style = 'width:200px' class = 'taskaboutdeal'><span class = 'myspan' style='margin-left:-40px;display:none'><a href='javaScript:;' class = 'deltaskaboutdeal' id = '${task.id}'><i class = 'icon-trash'></i></a><a>编辑</a></span><span><span style = 'margin-right:10px' id='num'><input id = '"+data.id+"' type='checkbox' style = 'margin-left:5px' class = 'mycheck'/></span><span  style = 'color:#fff;height:15px;background-color:"+data.taskType.color+";margin-right:5px'><font>"+data.taskType.typeContent+"</font></span><span>"+data.content+"</span></span></div>"); 
		 		
		 		}
		 		
		 	}
			if(type=="overdue"){
					 		
					 		$("#mytaskList").prepend("<h4 class = '"+type+" mydataType xxx' style = 'margin-bottom:5px;margin-top:8px;'>"+type+"</h4>");
					 		$(".xxx").after("<div style = 'width:200px' class = 'taskaboutdeal'><span class = 'myspan' style='margin-left:-40px;display:none'><a href='javaScript:;' class = 'deltaskaboutdeal' id = '${task.id}'><i class = 'icon-trash'></i></a><a>编辑</a></span><span><span style = 'margin-right:10px' id='num'><input id = '"+data.id+"' type='checkbox' style = 'margin-left:5px' class = 'mycheck'/></span><span  style = 'color:#fff;height:15px;background-color:"+data.taskType.color+";margin-right:5px'><font>"+data.taskType.typeContent+"</font></span><span>"+data.content+"</span></span></div>"); 
					 	}
					 	if(type == "tomorrow"){
					 		if($(".thisweek").length>0){
					 			$(".thisweek").insertBefore("<h4 class = '"+type+" mydataType xxx' style = 'margin-bottom:5px;margin-top:8px;'>"+type+"</h4>"); 
					 			$(".xxx").after("<div style = 'width:200px' class = 'taskaboutdeal'><span class = 'myspan' style='margin-left:-40px;display:none'><a href='javaScript:;' class = 'deltaskaboutdeal' id = '${task.id}'><i class = 'icon-trash'></i></a><a>编辑</a></span><span><span style = 'margin-right:10px' id='num'><input id = '"+data.id+"' type='checkbox' style = 'margin-left:5px' class = 'mycheck'/></span><span  style = 'color:#fff;height:15px;background-color:"+data.taskType.color+";margin-right:5px'><font>"+data.taskType.typeContent+"</font></span><span>"+data.content+"</span></span></div>"); 
					 		}else{
					 			if($(".nextweek").length>0){
					 				$(".thisweek").insertBefore("<h4 class = '"+type+" mydataType xxx' style = 'margin-bottom:5px;margin-top:8px;'>"+type+"</h4>"); 
					 				$(".xxx").after("<div style = 'width:200px' class = 'taskaboutdeal'><span class = 'myspan' style='margin-left:-40px;display:none'><a href='javaScript:;' class = 'deltaskaboutdeal' id = '${task.id}'><i class = 'icon-trash'></i></a><a>编辑</a></span><span><span style = 'margin-right:10px' id='num'><input id = '"+data.id+"' type='checkbox' style = 'margin-left:5px' class = 'mycheck'/></span><span  style = 'color:#fff;height:15px;background-color:"+data.taskType.color+";margin-right:5px'><font>"+data.taskType.typeContent+"</font></span><span>"+data.content+"</span></span></div>"); 
					 			}else{
					 				if($(".later").length>0){
					 					$(".later").insertBefore("<h4 class = '"+type+" mydataType xxx' style = 'margin-bottom:5px;margin-top:8px;'>"+type+"</h4>"); 
					 					$(".xxx").after("<div style = 'width:200px' class = 'taskaboutdeal'><span class = 'myspan' style='margin-left:-40px;display:none'><a href='javaScript:;' class = 'deltaskaboutdeal' id = '${task.id}'><i class = 'icon-trash'></i></a><a>编辑</a></span><span><span style = 'margin-right:10px' id='num'><input id = '"+data.id+"' type='checkbox' style = 'margin-left:5px' class = 'mycheck'/></span><span  style = 'color:#fff;height:15px;background-color:"+data.taskType.color+";margin-right:5px'><font>"+data.taskType.typeContent+"</font></span><span>"+data.content+"</span></span></div>"); 
						 			}else{
						 				$("#mytaskList").append("<h4 class = '"+type+" mydataType xxx' style = 'margin-bottom:5px;margin-top:8px;'>"+type+"</h4>");
					 					$(".xxx").after("<div style = 'width:200px' class = 'taskaboutdeal'><span class = 'myspan' style='margin-left:-40px;display:none'><a href='javaScript:;' class = 'deltaskaboutdeal' id = '${task.id}'><i class = 'icon-trash'></i></a><a>编辑</a></span><span><span style = 'margin-right:10px' id='num'><input id = '"+data.id+"' type='checkbox' style = 'margin-left:5px' class = 'mycheck'/></span><span  style = 'color:#fff;height:15px;background-color:"+data.taskType.color+";margin-right:5px'><font>"+data.taskType.typeContent+"</font></span><span>"+data.content+"</span></span></div>"); 
						 			
						 			}
					 			
					 			}
					 		
					 		}
					 	
					 	}
					 
					 
					 if(type == "thisweek"){
					 		if($(".nextweek").length>0){
					 			$(".nextweek").insertBefore("<h4 class = '"+type+" mydataType xxx' style = 'margin-bottom:5px;margin-top:8px;'>"+type+"</h4>"); 
					 			$(".xxx").after("<div style = 'width:200px' class = 'taskaboutdeal'><span class = 'myspan' style='margin-left:-40px;display:none'><a href='javaScript:;' class = 'deltaskaboutdeal' id = '${task.id}'><i class = 'icon-trash'></i></a><a>编辑</a></span><span><span style = 'margin-right:10px' id='num'><input id = '"+data.id+"' type='checkbox' style = 'margin-left:5px' class = 'mycheck'/></span><span  style = 'color:#fff;height:15px;background-color:"+data.taskType.color+";margin-right:5px'><font>"+data.taskType.typeContent+"</font></span><span>"+data.content+"</span></span></div>"); 
					 		}else{
					 			
			 				if($(".later").length>0){
			 					$(".later").insertBefore("<h4 class = '"+type+" mydataType xxx' style = 'margin-bottom:5px;margin-top:8px;'>"+type+"</h4>"); 
			 					$(".xxx").after("<div style = 'width:200px' class = 'taskaboutdeal'><span class = 'myspan' style='margin-left:-40px;display:none'><a href='javaScript:;' class = 'deltaskaboutdeal' id = '${task.id}'><i class = 'icon-trash'></i></a><a>编辑</a></span><span><span style = 'margin-right:10px' id='num'><input id = '"+data.id+"' type='checkbox' style = 'margin-left:5px' class = 'mycheck'/></span><span  style = 'color:#fff;height:15px;background-color:"+data.taskType.color+";margin-right:5px'><font>"+data.taskType.typeContent+"</font></span><span>"+data.content+"</span></span></div>"); 
				 			}else{
				 				$("#mytaskList").append("<h4 class = '"+type+" mydataType xxx' style = 'margin-bottom:5px;margin-top:8px;'>"+type+"</h4>");
			 					$(".xxx").after("<div style = 'width:200px' class = 'taskaboutdeal'><span class = 'myspan' style='margin-left:-40px;display:none'><a href='javaScript:;' class = 'deltaskaboutdeal' id = '${task.id}'><i class = 'icon-trash'></i></a><a>编辑</a></span><span><span style = 'margin-right:10px' id='num'><input id = '"+data.id+"' type='checkbox' style = 'margin-left:5px' class = 'mycheck'/></span><span  style = 'color:#fff;height:15px;background-color:"+data.taskType.color+";margin-right:5px'><font>"+data.taskType.typeContent+"</font></span><span>"+data.content+"</span></span></div>"); 
				 			}
					 	}
					 
					 }
					  if(type == "nextweek"){	
		 				if($(".later").length>0){
		 					$(".later").insertBefore("<h4 class = '"+type+" mydataType xxx' style = 'margin-bottom:5px;margin-top:8px;'>"+type+"</h4>"); 
		 					$(".xxx").after("<div style = 'width:200px' class = 'taskaboutdeal'><span class = 'myspan' style='margin-left:-40px;display:none'><a href='javaScript:;' class = 'deltaskaboutdeal' id = '${task.id}'><i class = 'icon-trash'></i></a><a>编辑</a></span><span><span style = 'margin-right:10px' id='num'><input id = '"+data.id+"' type='checkbox' style = 'margin-left:5px' class = 'mycheck'/></span><span  style = 'color:#fff;height:15px;background-color:"+data.taskType.color+";margin-right:5px'><font>"+data.taskType.typeContent+"</font></span><span>"+data.content+"</span></span></div>"); 
			 			}else{
			 				$("#mytaskList").append("<h4 class = '"+type+" mydataType xxx' style = 'margin-bottom:5px;margin-top:8px;'>"+type+"</h4>");
		 					$(".xxx").after("<div style = 'width:200px' class = 'taskaboutdeal'><span class = 'myspan' style='margin-left:-40px;display:none'><a href='javaScript:;' class = 'deltaskaboutdeal' id = '${task.id}'><i class = 'icon-trash'></i></a><a>编辑</a></span><span><span style = 'margin-right:10px' id='num'><input id = '"+data.id+"' type='checkbox' style = 'margin-left:5px' class = 'mycheck'/></span><span  style = 'color:#fff;height:15px;background-color:"+data.taskType.color+";margin-right:5px'><font>"+data.taskType.typeContent+"</font></span><span>"+data.content+"</span></span></div>"); 
			 			}
					 }
					  if(type == "later"){	
		 				if($(".later").length>0){
		 					$("."+v).after("<div style = 'width:200px' class = 'taskaboutdeal'><span class = 'myspan' style='margin-left:-40px;display:none'><a href='javaScript:;' class = 'deltaskaboutdeal' id = '${task.id}'><i class = 'icon-trash'></i></a><a>编辑</a></span><span><span style = 'margin-right:10px' id='num'><input id = '"+data.id+"' type='checkbox' style = 'margin-left:5px' class = 'mycheck'/></span><span  style = 'color:#fff;height:15px;background-color:"+data.taskType.color+";margin-right:5px'><font>"+data.taskType.typeContent+"</font></span><span>"+data.content+"</span></span></div>"); 
			 			}else{
			 				$("#mytaskList").append("<h4 class = '"+type+" mydataType xxx' style = 'margin-bottom:5px;margin-top:8px;'>"+type+"</h4>");
		 					$(".xxx").after("<div style = 'width:200px' class = 'taskaboutdeal'><span class = 'myspan' style='margin-left:-40px;display:none'><a href='javaScript:;' class = 'deltaskaboutdeal' id = '${task.id}'><i class = 'icon-trash'></i></a><a>编辑</a></span><span><span style = 'margin-right:10px' id='num'><input id = '"+data.id+"' type='checkbox' style = 'margin-left:5px' class = 'mycheck'/></span><span  style = 'color:#fff;height:15px;background-color:"+data.taskType.color+";margin-right:5px'><font>"+data.taskType.typeContent+"</font></span><span>"+data.content+"</span></span></div>"); 
			 			}
					 }
		
		
		
		}
		$(".mycheck").live("click",function(){
			var v =$(this).attr("checked");
			var id = $(this).attr("id");
			$.get("<%=basePath%>task/deltask.action?id="+id,function(data){
			});
			$(this).parent().parent().css("text-decoration","line-through");
			$(this).parent().parent().fadeOut(1500);
			
			
			
		
		
		});
		$(".deltaskaboutdeal").live("click",function(){
			var id = $(this).attr("id");
			$.get("<%=basePath%>task/deltask.action?id="+id,function(data){
			});
			$(this).parent().parent().css("background-color","yellow");
			$(this).parent().parent().fadeOut(1500);
		
		
		
		
		
		});
		
		
	
			$('#settimebtn').click(function(){
				$("#selecttime").hide();
				$("#settimeinput").show();
			});
			$('#settimebtn').datepicker().on('changeDate',function(ev){
				$("#settimeinput").attr("value",$('#settimebtn').data('date'));
			});
			$('#settimebtn1').click(function(){
				$("#selecttime1").hide();
				$("#settimeinput1").show();
			});
			$('#settimebtn1').datepicker().on('changeDate', function(ev){
				$("#settimeinput1").attr("value",$('#settimebtn1').data('date'));
			});
			$("#toAdd").click(function(){
				var dealContact = $("#dealContact3").attr("value");
				//alert(dealContact);
				var contactid = $("#searchhidden").attr("value");
				var dealid = $("#searchdealid").attr("value");
				//alert(dealid);
				$.get("<%=basePath%>dealContact/add.action?contactid="+contactid+"&dealid="+dealid,function(data){
					alert(data);
					if(data.type == 'person'){
						$("#toaddContact").append($("<div style = 'margin-bottom:20px'><img src = '<%=basePath%>img/3.png' style = 'width:30px;height:30px;margin-left:25px'/><span style = 'margin-left:15px'><strong><a class='dc2' id='"+data.id+"' href='<%=basePath%>contact/singlecontact.action?id="+data.id+"'>"+data.name+"</a></strong><a href='javaScript:;' class='editdcContact' id='"+data.id+"'><i class='icon-trash'></i></a></span></div>"));
					}
					if(data.type == 'company'){
						$("#toaddContact").append($("<div style = 'margin-bottom:20px'><img src = '<%=basePath%>img/10.png' style = 'width:30px;height:30px;margin-left:25px'/><span style = 'margin-left:15px'><strong><a class='dc2' id='"+data.id+"' href='<%=basePath%>contact/singlecontact.action?id="+data.id+"'>"+data.name+"</a></strong><a href='javaScript:;' class='editdcContact' id='"+data.id+"'><i class='icon-trash'></i></a></span></div>"));
						
					}
					$(".searchothercontact").hide();
					
				});
			
			
			});
			$("#searchContact").live("keyup",function(){
					var v = this.value;
					if(v.length>0){
						$.get("<%=basePath%>contact/search.action?q_pinyin="+v,function(data){
							$(".show").show();
							
							if(data.length == 0){
								$(".show").empty();
								$(".show").append($("<span>没有适合的人选</span>"));
							}else{
								//情况div中元素
								$(".show").empty();
								$(".show").append($("<ul class='nav nav-list myul'><li></li><li>点击你想要选的人</li></ul>"));
								for(var i=0;i<data.length;i++){
									$(".myul").append($("<li class = 'myli' id = "+data[i].type+"><a href = 'javaScript:;' class ='mya' id="+data[i].id+">"+data[i].name+"</a></li>"));
								}
							}
						}); 
					}
				});
			$(".mya").live("click",function(){
					var v = $(this).html();
					var id = $(this).attr("id");
					$("#searchContact").attr("value",v);
					$("#searchhidden").attr("value",id);
					$(".show").hide();
					
				});
			var m = 1;
			$("#addothercontact").click(function(){
				if(m==1){
					$(".searchothercontact").show();
					m=0;
				}else{
					$(".searchothercontact").hide();
					m=1;
				}
			});
			$(".delnote").click(function(){
				if(confirm("你确定要删除吗？")){
						var id = $(this).attr("id");
						//alert(id);
						//alert($(this).parent().parent().attr("id"));
						$.get("<%=basePath%>note/delnote.action?id="+id,function(data){
							//删除 这个元素,在这里无法删除 为什么？？？
							/*$(this).parent().parent().remove();*/
						
						});
						//删除 这个元素
						$(this).parent().parent().fadeOut(1500);
						
				
				}
				
				
			});
			$(".editnote").click(function(){
				var id = $(this).attr("id");
				//alert(id);
			
			});
			$(".mymouseover").mousemove(function(){
				$(this).children(".myeditanddel").show();
				$(this).children(".tocomment").show();
				
			});
			$(".taskaboutdeal").live("mousemove",function(){
				$(this).children(".myspan").show();
				
				
			});
			$(".taskaboutdeal").live("mouseout",function(){
				$(this).children(".myspan").hide();
				
				
			});
			$(".mymouseover").mouseout(function(){
				$(this).children(".myeditanddel").hide();
				$(this).children(".tocomment").hide();
			});
			$("#myform").click(function(){
				alert("hhe");
				$("#form").submit();
			});
			var result = 1;
			$(".showOptions").live("click",function(){
				if(result == 1){
					$(this).next("#myhiddennote").show();
					result = 0;
				}else{
					$(this).next("#myhiddennote").hide();
					result = 1;
				}
				
			});
			$(".quxiao").live("click",function(){
				
			
			
			});
			
			$("#radiobtn").click(function(){
				$("#showSelect").show();
			});
			
			$("#pend").click(function(){
				var v = "pend";
				$.get("<%=basePath%>deal/updatestate.action?id=${param.id}&progress="+v,function(data){
					$("#pend").attr("class","btn btn-danger");
					$("#won").attr("class","btn");
					$("#lost").attr("class","btn");
					$("#aboutnote").append($("<div style = 'margin-bottom:20px;background-color:#ededed;height:30px'><div style = 'background-color:#666;width:60px;height:20px;color:white;text-align:center;padding-top:4px;border-radius:6px 6px'>跟进</div><div style = 'margin-left:80px;margin-top:-20px;'>"+data.content+"</div></div>"));
					
				});	
			});
			$("#won").click(function(){
				var v = "won";
				$.get("<%=basePath%>deal/updatestate.action?id=${param.id}&progress="+v,function(data){
					$("#won").attr("class","btn btn-success");
					$("#pend").attr("class","btn");
					$("#lost").attr("class","btn");
					$("#aboutnote").append($("<div style = 'margin-bottom:20px;background-color:#ededed;height:30px'><div style = 'background-color:#51a351;width:60px;height:20px;color:white;text-align:center;padding-top:4px;border-radius:6px 6px'>赢得</div><div style = 'margin-left:80px;margin-top:-20px;'>"+data.content+"</div></div>"));
				});	
			});
			$("#lost").click(function(){
				var v = "lost";
				$.get("<%=basePath%>deal/updatestate.action?id=${param.id}&progress="+v,function(data){
					$("#lost").attr("class","btn active");
					$("#won").attr("class","btn");
					$("#pend").attr("class","btn");
					$("#aboutnote").append($("<div style = 'margin-bottom:20px;background-color:#ededed;height:30px'><div style = 'background-color:#900;width:60px;height:20px;color:white;text-align:center;padding-top:4px;border-radius:6px 6px'>失去</div><div style = 'margin-left:80px;margin-top:-20px;'>"+data.content+"</div></div>"));
				});
			});
			$("#d1").datepicker();	
			$("#d2").datepicker();	
			$(".editnote").live("click",function(){
				
				var id = $(this).attr("id");
				$(".enote").each(function(){
					alert("hehe");
					$(this).removeClass(".enote");
				
				});
				$(this).parent().parent().addClass("enote");
				$(this).parent().parent().empty();
				$.get("<%=basePath%>note/editnote.action?id="+id,function(data){
					
					$(".enote").append("<span style='margin-left:20px;'>编辑记录</span><div  style = 'margin-left:20px;width:470px;margin-left:20px;background-color:#fff;box-shadow:rgba(0, 0, 0, 0.2) 0px 0px 4px;border:1px solid #ccc;'><textarea  name = '' id ='"+data.id+"' class='eidtnotecontent' style = 'width:400px;overflow-y:visible;margin:20px;height:120px;'>"+data.content+"</textarea><a class='showOptions' href='javaScript:;'style='margin-left:20px;'>选择更多...</a>(如：可见权限设置，选择具体的相关联系人)<div id='myhiddennote' style='display:none;margin-left:20px'><br/><strong>与这个记录相关的联系人</strong><br><p style = 'font-size:12p' class=' mytip'>(*选择与这笔交易相关的人或者是公司)</p><select name ='contactid' id = 'contactid' class='aboutcon'></select><br><strong>设置可见的权限</strong>	<br><input type ='radio'  name ='note.views' value='all'>所有人 <br/><input type ='radio' name ='note.views' value='me'>只有我<br/><input type ='radio' name ='note.views' id = 'radiobtn' value='all,other'>我,和下面这些人<br/><div id='showSelect' style='display:none;'><select name=''  ><option value=''>请选择</option><option value=''>张三</option><option value=''>王五</option><option value=''>李四</option><option value=''>小妹</option></select></div><strong>记录具体发生的日期</strong><p>Date: <input name ='note.createtime' type='text' id='d2' value ='"+data.createtime+"'></p></div><button id = 'editnotebtn3' style = 'margin-left:350px;margin-right:10px' class = 'btn btn-success'>修改</button><a class='quxiao' href = 'javaScript:;'; style='margin-top:-40px;'>取消</a></div>");
					
					$(".dc2").each(function(){
						var i = $(this).attr("id");
						var name = $(this).html();
						$(".aboutcon").append($("<option class='myc2' value='"+i+"'>"+name+"</option>"));
					});
					if(data.contact!=null){
						 $(".myc2").each(function(){
						 	var v = $(this).html();
						 	if(v==data.contact.name){
						 		$(this).attr("selected","selected");
						 	
						 	}
						 
						 });
					
					}
					
				});
				
				
				
		
		
			});
			$("#editnotebtn3").live("click",function(data){
				alert("xxx");
				var m = $(".eidtnotecontent").val();
				var type;
				var content;
				var id = $(".eidtnotecontent").attr("id");
				$(this).parent().parent().addClass("editSuccess");
				$(this).parent().parent().empty();
				$.get("<%=basePath%>note/toeditnote.action?id="+id+"&content="+m,function(data){
					if(type="note"){
						$(".editSuccess").append($("<a class = 'tocomment' style = 'float:right;display:none' href = 'javaScript:;' class ='editnote'>查看记录并评论</a><div class = 'myeditanddel' style = 'float:left;display:none;margin-left:-40px;'><a href='javaScript:;' id = '"+data.id+"' class ='delnote' ><i class = 'icon-trash'></i></a><a href='javaScript:;' id = '"+data.id+"' class ='editnote'>编辑</a></div><img src = '<%=basePath %>img/10.png'/><div style = 'margin-left:80px;margin-top:-45px;'><strong>"+data.createtime+"</strong><br/><span style = 'color:red'>"+data.user.username+"&nbsp;&nbsp;&nbsp;&nbsp;</span>添加的记录<br/><span></span><br><br><div style = 'margin-left:0px;border-bottom:1px solid #dcdcdc;'>"+data.content+"</div></div></div>"));
				
					}
			
			
			
				});
				
				
				
				
			});
				
			$(".editdcContact").live("click",function(){
				var id = $(this).attr("id");
				
				var m= $("#getDealid").attr("value");
				$.get("<%=basePath%>dealContact/delAboutContact.action?contactid="+id+"&dealid="+m,function(data){
					
				
				
				
				});
				$(this).parent().parent().fadeOut(1000);
			
			
			
			
			
			
			
			});
				
				
				
				
			
			
			
			
			
			
			
		});
		
		
	</script>
	<script>
	
	</script>
</body>
</html>
